package com.swak.lock;

import java.io.File;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.nio.file.StandardOpenOption;

public class FileLockTest1 {

	public static void main(String[] args) throws IOException, InterruptedException {
		File lockFile = new File("D:\\none.txt");
		FileLock locked1 = FileChannel.open(lockFile.toPath(), StandardOpenOption.WRITE).tryLock();
		System.out.println(locked1);
		
		Thread.sleep(10000000);
	}
}
